package com.xcf.controller.business.common;

import java.util.List;
import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.xcf.controller.base.BaseController;
import com.xcf.service.business.common.domesticroute.DomesticRouteMaintainService;
import com.xcf.util.PageData;
/**
 * 国内航线维护
 * @author tanwei
 *
 */

@Controller
@RequestMapping(value="/domesticRouteMaintain")
public class DomesticRouteMaintainController extends BaseController{
	String menuUrl = "domesticRouteMaintain/list";
	@Resource
	private DomesticRouteMaintainService domesticRoute;
@RequestMapping(value="/list")
 public ModelAndView domesticRouteMaintainList() throws Exception{
	ModelAndView view = new ModelAndView();
	PageData pd = new PageData();
	pd = this.getPageData();
	List<PageData> domesticRouteInfo = domesticRoute.findDomesticRouteMaintainInfo(pd);
	view.addObject("domesticRoute",domesticRouteInfo);
//         JSONArray jarr = JSONArray.fromObject(domesticRouteInfo);
//         JSONObject obj = new JSONObject();
//         obj.put("domesticRouteInfo", jarr);
//         resp.setContentType("text/html; charset=utf-8");
//         resp.getWriter().write(obj.toString());

	view.setViewName("/business/common/domesticroute/domestic_route_maintain_list");
	return view;
	 
 }
/**
 * 保存或修改数据
 * @return
 * @throws Exception
 */
@RequestMapping(value="/addDomesticRouteMaintainInfo")
@ResponseBody
public String addDomesticRouteMaintainInfo()throws Exception{
	PageData pd = new PageData();
	pd = this.getPageData();
	
	if(pd.getString("ID")==null || pd.getString("ID")==""){
		domesticRoute.saveDomesticRouteMaintainInfo(pd);
		}else{
		domesticRoute.updateDomesticRouteMaintain(pd);
		}
	return null;
	
}
/**
 * 国内航线维护编辑页面
 * @return
 * @throws Exception
 */
@RequestMapping(value="/editDomesticRouteMaintainInfo")
public ModelAndView editDomesticRouteMaintainInfo()throws Exception{
	PageData pd = new PageData();
	pd = this.getPageData();
	ModelAndView view = new ModelAndView();
	pd = domesticRoute.findDomesticRouteMaintainInfoById(pd);
	view.addObject("pd",pd);
	view.setViewName("/business/common/domesticroute/domestic_route_maintain_edit");
	return view;
	
}
/**
 * 删除运输条款信息
 * @return
 * @throws Exception
 */
@RequestMapping(value="/deleteDomesticRouteMaintainInfo")
@ResponseBody
public String deleteDomesticRouteMaintainInfo() throws Exception{
	PageData pd = new PageData();
	pd = this.getPageData();
	domesticRoute.deleteDomesticRouteMaintain(pd);
	return null;
}
}
